package com.zbw.weightlibrary.Connector;

import android.content.Context;

import com.zbw.weightlibrary.WeightSub.BalanceScale;
import com.zbw.weightlibrary.WeightSub.DaHuaSerialPort;
import com.zbw.weightlibrary.WeightSub.DingJianOS2X;
import com.zbw.weightlibrary.WeightSub.DingJianSerialPort;
import com.zbw.weightlibrary.WeightSub.EScale;
import com.zbw.weightlibrary.WeightSub.Histone;
import com.zbw.weightlibrary.WeightSub.LinLuoSerialPort;
import com.zbw.weightlibrary.WeightSub.MeiTuanL4;
import com.zbw.weightlibrary.WeightSub.OnePlusOne;
import com.zbw.weightlibrary.WeightSub.QiHuaSerialPort;
import com.zbw.weightlibrary.WeightSub.RongDaSerialPort;
import com.zbw.weightlibrary.WeightSub.SunmiUtil;
import com.zbw.weightlibrary.WeightSub.WINTECSerialPort;
import com.zbw.weightlibrary.WeightSub.WeightBluetooth;
import com.zbw.weightlibrary.WeightSub.WeightRuiJian;
import com.zbw.weightlibrary.WeightSub.WeightSerialPort;
import com.zbw.weightlibrary.WeightSub.WeightUsbToSerial;
import com.zbw.weightlibrary.WeightSub.ZhongQiSerialPort;

/**
 * 作者 ：Wesley
 * 时间 ：2019-02-19 15:12
 * 这个类是干嘛的？：NewWeight
 */
public class NewWeight {
    public static final int SUNMI_WEIGHT = 102;//商米电子秤
    public static final int WEIGHTBLUETOOTH = 105;//蓝牙电子秤
    public static final int WEIGHTSERIAL = 106;//串口电子秤
    public static final int WEIGHTUSBTOSERIAL = 107;//USB转串口电子秤
    public static final int USB_DINGJIAN_OS2X = 108; // 顶尖os2x型号 usb电子秤
    public static final int WEIGHTRUIJIAN = 109;//串口，锐箭1010电子秤
    public static final int DAHUA = 110;//串口，大华串口秤
    public static final int DINGJIAN_SERIAL_WEIGHT = 111;//串口，顶尖串口秤
    public static final int ZHONGQI = 112;//串口，中琦串口秤
    public static final int LINLUO = 113;//串口，麟罗串口秤
    public static final int WINTEC = 114;//一体秤，中科英泰

    public static final int MEITUANL4 = 115;//一体秤，美团L4

    public static final int BALANCE = 116;//佰伦斯一体秤

    public static final int RONGDA = 117;//荣大串口秤

    public static final int OnePlusOne = 118;//壹佳一秤

    public static final int QiHua = 119;//七华一体秤

    public static final int EScale = 120;//EScale电子秤 一敏

    public static final int Histone = 121;//Histone电子秤 海信

    private static volatile NewWeight mInstance;
    public static int ModelRecord;//用于临时记录连接的机型

    private NewWeight() {
    }

    public static NewWeight getInstance() {
        if (mInstance == null) {
            synchronized (NewWeight.class) {
                if (mInstance == null) {
                    mInstance = new NewWeight();
                }
            }
        }
        return mInstance;
    }

    public IBleControl NewControl(int type, Context context, IinfoCallback callback, WeightData data) {
        IBleControl iControl = null;
        ModelRecord = type;
        switch (type) {
            case SUNMI_WEIGHT:
                iControl = new SunmiUtil(context, callback);
                break;
            case WEIGHTBLUETOOTH:
                iControl = new WeightBluetooth(context, callback, data);
                break;
            case WEIGHTSERIAL:
                iControl = new WeightSerialPort(context, callback, data);
                break;
            case WEIGHTRUIJIAN:
                iControl = new WeightRuiJian(context, callback, data);
                break;
            case WEIGHTUSBTOSERIAL:
                iControl = new WeightUsbToSerial(context, callback, data);
                break;
            case USB_DINGJIAN_OS2X:
                iControl = new DingJianOS2X(context, callback);
                break;
            case DAHUA:
                iControl = new DaHuaSerialPort(context, callback, data);
                break;
            case DINGJIAN_SERIAL_WEIGHT:
                iControl = new DingJianSerialPort(context, callback, data);
                break;
            case ZHONGQI:
                iControl = new ZhongQiSerialPort(context, callback, data);
                break;
            case LINLUO:
                iControl = new LinLuoSerialPort(callback, data);
                break;
            case WINTEC:
                iControl = new WINTECSerialPort(context, callback);
                break;
            case MEITUANL4:
                iControl = new MeiTuanL4(context, callback);
                break;
            case BALANCE:
                iControl = new BalanceScale(context, callback);
                break;
            case RONGDA:
                iControl = new RongDaSerialPort(callback, data);
                break;
            case OnePlusOne:
                iControl = new OnePlusOne(context, callback);
                break;
            case QiHua:
                iControl = new QiHuaSerialPort(callback, data);
                break;
            case EScale:
                iControl = new EScale(context, callback);
                break;
            case Histone:
                iControl = new Histone(context, callback);
                break;
            default:
                break;
        }
        return iControl;
    }
}
